
$(function() {
	
	$("#from_s:visible").autocomplete(Test.emp);		
});

var Notice = {

	popup: function (e, p2, id, status) {
		$.cookie('id_', id);

		p2 = query(p2);
		$.cookie('p2', p2);

		var c1 = 'log.php?do=NoticeMy.edit&id=' + id;
		var c2 = 'log.php?do=NoticeMy.view&id=' + id;
				
		var cs = 'log.php?do=NoticeMy.status&id=' + id;
		
		var a2 = ['查看信息', 'url', 'Notice.dialog_view_', '650x400'];
					
		var s = c2;

		return popup(e, [a2], s);
	},
	
	view: function(p2, id) {
		$.cookie('id_', id);
		
		p2 = query(p2);
		$.cookie('p2', p2);
		
		var url = 'log.php?do=NoticeMy.view&id=' + id;
		
		this.dialog_view_(url, '查看信息', '650x400');
	},
	
	dialog_view_: function (url, title, xy) {
		var result = Common.result();
		$('#dialog_view').dialog('option', 'buttons', {
			"关闭": function() { 
				$(this).dialog("close");
			},
			
			"已读": function() { 
				if (!confirm("确认是否已读？")) {
					return false;
				}				
				
				var body = {};
				body.id = $.cookie('id_');
				body.status = 2;
				
				$(this).dialog("close");

				var url = 'log.php?do=NoticeMy.status';
				var p2 = $.cookie('p2');
				if (p2 != null) {
					url += p2;
				}

				$.post(url, body, function(data) {
					$(result).html(data);
				});
			}
		});

		dialog_view(url, title, xy);
	},
	
	all: function (e, p2) {
		p2 = query(p2);
		$.cookie('p2', p2);

		var c1 = 'log.php?do=NoticeMy.delete' + p2;
		var c2 = 'log.php?do=NoticeMy.batch_status';
					
		var a1 = ['删除信息', 'url', 'Common.list_delete'];
		var a2 = ['设置已读', 'url', 'Notice.list_status'];
		
		var s = c1 + ", " + c2;

		return popup(e, [a1, a2], s);
	},
	
	list_status: function (url, view) {		
		var result = Common.result();
		var c = new Array();
		$("input[name^='c_']").each(function() {
			if ($(this).attr("checked")) {
				var s = encodeURIComponent(this.name) + "=" + encodeURIComponent($(this).val());
				c.push(s);
			}
		});
		
		var body = c.join("&");
		
		if (confirm("您确定把已选择的" + c.length + "条记录设置为已读吗？")) {
			// $.blockUI({ message: $('#loading') });

			$.get(url, body, function(data) {
				$(result).html(data);
			});
			
			return true;
		}
	}
};
